Processor core and multiplier that support a multiply and difference operation by inverting sign bits in booth recoding

ABSTRACT

The present invention provides processing systems, apparatuses, and methods that support both general processing processor (GPP) and digital signal processor (DSP) features, such as vector and single value multiplication. In an embodiment, fractional arithmetic, integer arithmetic, saturation, and single instruction multiple data (SIMD) operations such as vector multiply, multiply accumulate, dot-product accumulate, and multiply-subtract accumulate are supported. In an embodiment, the process core and/or multiplier multiplies vector values or single values by creating partial products for each desired product. These partial products are added to produce intermediate results, which are combined in different ways to support various GPP and DSP operations.

CROSS REFERENCE TO RELATED APPLICATIONS

This application is related to commonly owned, co-pending U.S.application Ser. No. 11/121,945, filed on the same date herewith,entitled “Processor Core and Multiplier That Support Both Vector andSingle Value Multiplication,” which is incorporated herein by referencein its entirety.

FIELD OF THE INVENTION

The present invention relates generally to processor cores andmultipliers that are capable of supporting both vector and single valuemultiplication.

BACKGROUND OF THE INVENTION

Traditionally, the functionality of general purpose processors (GPPs)and digital signal processors (DSPs) have been implemented separately asindividual processors. But, as modern applications, for example, DVDrecorders, cable set-top boxes, VoIP systems, and MP3 players demandboth general purpose processing and digital signal processingcapabilities, and as GPPs become faster, the trend has been to convergethe functionality of GPPs and DSPs into a single processor.

BRIEF SUMMARY OF THE INVENTION

The present invention provides processing systems, apparatuses, andmethods that support both GPP and DSP features, such as vector andsingle value multiplication. In an embodiment, the present inventionsupports fractional arithmetic, integer arithmetic, saturation, and SIMD(Single Instruction Multiple Data) operations such as vector multiply,multiply accumulate, dot-product accumulate, multiply-differenceaccumulate, and dot-product subtract accumulate.

In an embodiment, the present invention multiplies vector values orsingle values by creating partial products for each desired product.These partial products are added by hardware components to produceintermediate results, which are combined in different ways to supportvarious GPP and DSP operations.

In an embodiment, the present invention supports multiply-difference andmultiply-difference accumulate operations by applying negated Boothrecoding to generate a first product of vector values and by applyingnormal Booth recoding to generate a second product of vector values.

Further embodiments, features, and advantages of the present invention,as well as the structure and operation of the various embodiments of thepresent invention, are described in detail below with reference to theaccompanying drawings.

BRIEF DESCRIPTION OF THE DRAWINGS/FIGURES

The accompanying drawings, which are incorporated herein and form a partof the specification, illustrate the present invention and, togetherwith the description, further serve to explain the principles of theinvention and to enable a person skilled in the pertinent art to makeand use the invention.

FIG. 1 is a schematic diagram of a processor core according to anembodiment of the present invention.

FIG. 2A-2B are diagrams illustrating how a vector and a single value arerepresented as a 32-bit operand.

FIGS. 3A-3D are diagrams illustrating SIMD (Single Instruction MultipleData) operations that are supported by the processor core of FIG. 1.

FIG. 4 is a more detailed schematic diagram of the multiplier of FIG. 1.

FIG. 5A-5B are more detailed schematic diagrams of the multiplier ofFIG. 4.

FIG. 6 is a flow chart illustrating the steps of a first methodembodiment of the present invention.

FIG. 7 is a flow chart illustrating the steps of a second methodembodiment of the present invention.

FIGS. 8A-8G are diagrams illustrating various instructions that can beimplemented by the processor core of FIG. 1.

The present invention will be described with reference to theaccompanying drawings. The drawing in which an element first appears istypically indicated by the leftmost digit(s) in the correspondingreference number.

DETAILED DESCRIPTION OF THE INVENTION

The present invention provides processing systems, apparatuses, andmethods that support both GPP and DSP features, such as vector andsingle value multiplication. In the detailed description of theinvention that follows, references to “one embodiment”, “an embodiment”,“an example embodiment”, etc., indicate that the embodiment describedmay include a particular feature, structure, or characteristic, butevery embodiment may not necessarily include the particular feature,structure, or characteristic. Moreover, such phrases are not necessarilyreferring to the same embodiment. Further, when a particular feature,structure, or characteristic is described in connection with anembodiment, it is submitted that it is within the knowledge of oneskilled in the art to effect such feature, structure, or characteristicin connection with other embodiments whether or not explicitlydescribed.

FIG. 1 is a schematic diagram of a processor core 100 according to anembodiment of the present invention. Processor core 100 includes ageneral execution unit 126 and a multiply/divide unit 128. Generalexecution unit 126 includes a set of general purpose registers (GPRs)102 and a general integer execution logic 104. Multiply/divide unit 128includes logic for a multiplier 106, logic for performing division (notshown) and a set of accumulation registers 108. Multiplier 106 supportsa variety of operands representing both vectors and single values.

In an embodiment, GPRs 102 provide operands 120 and 122 (e.g., thevalues in a first and second register) to general integer executionlogic 104. For operations that require multiplication or division,general integer execution logic 104 passes values represented byoperands 120 and 122 to multiply/divide unit 128 as operands 110 and112. Multiplier 106 receives operands 110 and 112 and an operand 114from one of accumulation registers 108 and generates a result 116 or118. Result 116 is stored in one of accumulation registers 108. Result118 is passed to general integer execution logic 104, which is thenpassed to GPRs 102 as result 124 and stored in a register of GPRs 102.

FIG. 2A is diagram illustrating how a single value is represented as a32-bit operand. All 32-bits of operand 200 are reserved to represent avalue, for example, single signed or unsigned 8-bit, 16-bit, or 32-bitinteger value, as well as a 16-bit fractional (Q15) or 32-bit fractional(Q31) value. FIG. 2B is a diagram illustrating how a vector isrepresented as a 32-bit operand. Bits 0 to 15 of operand 202 arereserved to represent a right vector value 204 and bits 16 to 31 arereserved to represent a left vector value 206. Vector values 204 and 206may each be, for example, a signed or unsigned 8-bit or 16-bit integervalue or a 16-bit fractional (Q15) value. As would be appreciated bypersons skilled in the relevant art, different formats as well asdifferent sized operands may be used with the present invention torepresent both vectors and single values. Furthermore, as would beappreciated by persons skilled in the relevant art, different data typesmay be used to represent vector values and single values.

Referring to FIG. 1 again, Multiplier 106 supports a variety ofoperations that operate on vectors and single values such as thoseillustrated by FIGS. 2A and 2B. For example, multiplier 106 may supporta multiply (MULT) instruction wherein multiplier 106 multiplies two32-bit integer single values represented by operands 110 and 112 toproduce a 64-bit result 116. The result 116 is stored, for example, inone of accumulation registers 108. Multiplier 106 also supports amultiply and accumulate (MAQ) instruction wherein multiplier 106multiplies two Q15 single values represented by operands 110 and 112 toproduce a Q31 value. This value may be added with a value represented byoperand 114 to produce a 64-bit result 116 that is stored in one ofaccumulation registers 108.

In an embodiment, multiplier 106 supports SIMD (Single InstructionMultiple Data) operations.

FIGS. 3A-3D are diagrams illustrating SIMD (Single Instruction MultipleData) operations that are supported by processor core 100. FIG. 3A is adiagram illustrating a multiply vector SIMD instruction (MULQ). Operands110 and 112 each hold vectors containing two Q15 values (i.e. values300, 302, 304, and 306). To perform a MULQ operation, multiplier 106multiplies right vector values 300 and 304 to produce right vector value308 of result 118. Multiplier 106 multiplies left vector values 302 and304 to produce left vector value 310 of result 118. FIG. 3B is a diagramillustrating a dot-product accumulate SIMD instruction (DPA). To performa DPA operation, multiplier 106 sums the product of right vector values300 and 304, the product of left vector values 302 and 306, and value312 represented by operand 114 to generate value 314 of result 116. FIG.3C is a diagram illustrating a multiply-difference accumulate SIMDinstruction (MULSAQ). To perform a MULSAQ operation, multiplier 106 sumsthe negative value of the product of right vector values 300 and 304,the product of left vector values 302 and 306, and value 312 representedby operand 114 to generate value 316 of result 116. FIG. 3D is a diagramillustrating a dot-product subtract accumulate operation (e.g., DPS). Toperform a DPS operation, multiplier 106 subtracts the sum of the productof right vector values 300 and 304 and the product of left vector values302 and 306 from value 312 represented by operand 114 to generate value318 of result 116. Embodiments of the present invention can supportadditional SIMD instructions.

FIG. 4 is a more detailed schematic diagram of multiplier 106.Multiplier 106 includes a partial product generator 400, adder arrays402 and 404 and a combiner 406.

Partial product generator 400 receives operands 110 and 112 andgenerates sets of partial products 408 and 410. When operands 110 and112 represent vectors, partial product generator 400 generates sets 408and 410 such that the sum of the partial products in set 408 equals theproduct of the right vector values and the sum of partial products inset 410 equals the product of the left vector values. When operands 110and 112 each represent a single value, partial product generator 400generates sets 408 and 410 such that the sum of all the partial productsin both sets equals the product of the single values.

Adder arrays 402 and 404 sum the partial products generated by partialproduct generator 400. Adder array 402 receives and adds the partialproducts in set 408 to generate a result 412. Likewise, adder array 404receives and adds the partial products in set 410 to generate a result414. When adder arrays 402 and 404 are implemented, for example, usingcarry-save adders, results 412 and 414 each contain two values, thecarry and the save of the carry-save addition. In an embodiment thatuses for example ripple-adders or carry-lookahead adders, results 412and 414 each represent a single value, the sum of the partial productsin sets 408 and 410, respectively. Adder arrays 402 and 404 may beimplemented using a variety of different adders and is not limited tobeing implemented using just ripple-adders, carry-lookahead adders,and/or carry-save adders.

As noted herein, results 412 and 414 represent either products of vectorvalues or partial sums of the product of single values. In anembodiment, this is possible because partial product generator 400provides partial products for the product of right vector values toadder array 402 and provides partial products of left vector values toadder array 404. Hence, combiner 406 can produces different finalresults 116 and 118 by combining results 412, 414, and value representedby operand 114 in various ways. When operands 110 and 112 each representa single value, the combiner 406 can add result 412, result 414, andoptionally the value of operand 114 to generate result 116, therebysupporting operations such as MULT and MAQ. When operands 110 and 112represent vectors, combiner 406 combines results 412 and 414 to generatea vector for result 118, thereby supporting MULQ type operations.Furthermore, when operands 110 and 112 represent vectors, combiner 406adds and subtracts results 412, result 414, and the value represented byoperand 114 to provide result 116, thereby supporting DPA, MULSAQ, andDPS type operations.

In an embodiment, combiner 406 provides support for fractional values.Fractional values are used to represent a range of +1 to −1. Forfractional values encoded as two's complement fixed-point integervalues, the full range of integer values (i.e., −32768 to 32767 for a16-bit integer) are generally used to represent the range +1 to −1 asclosely as possible. Hence, when a fractional number is represented as a16-bit integer, the value 0x8000 (−32768) is generally used to represent−1 and the value 0x7FFF (32767) is generally used to represent 0.999999.Using this scheme, it is not possible to represent +1 since +32768cannot be represented in two's complement 16-bit integer format. Whentwo fractional values, which are represented as two's complementfixed-point integers, are multiplied together utilizing integermultiplier, the result must be shifted by one bit in the direction ofthe most significant bit to align the decimal point of the fractionalproduct. Hence, when operands 110 and 112 represent vector values orsingle values that are 32-bit fractional (Q31) or 16-bit fractional(Q15) numbers, combiner 406 shifts results of 412 and/or 414 to properlyalign the decimal point of the resulting fractional products.

In an embodiment, combiner 406 provides saturation support forfractional values. Since a two's complement fixed-point integerrepresentation of fractional values is able to represent values between+1 and −1 exclusively and −1, an overflow condition arising from themultiplication of two fractional values can occur only when twofractional values are equal to −1. When fractional values in theoperands 110 and 112 are detected such that multiplication of thosevalues will result in a fractional overflow, combiner 406 saturates theresult 412 and/or 414 so that the result of the fractionalmultiplication is as close to 1 as possible (i.e., 0.999999).

FIG. 5A-5B are detailed schematic diagrams of multiplier 106. Morespecifically, FIG. 5A provides greater detail of partial productgenerator 400 and adder arrays 402 and 404. FIG. 5B provides greaterdetail of combiner 406.

Referring to FIG. 5A, partial product generator 400 includes a Boothrecoder 500 and a partial product selector 502. Booth recoder 500generates Booth recoded values 534. These values include Booth recodedmultipliers and Booth recoded partial product values for either vectorvalues or single values represented by operands 110 and 112.

To better understand the present invention, consider an example of longhand multiplication. Long hand multiplication generates a product of twon-bit binary numbers. For each bit in the multiplier value, a 2n-bitpartial product is generated. When the bit is a one value, this partialproduct contains a copy of the multiplicand value that is logicallyshifted toward the most significant bit (i.e., such that the leastsignificant bit of the copy of the multiplicand value appears in thepartial product at the position that the one bit value appears in themultiplier value). The copy of the multiplicand value may be signextended when generating the partial product if the multiplicand valueis signed. After all n partial products are created, one for each bit inthe multiplier value, they are summed to generate a 2n-bit product ofthe two n-bit binary numbers.

A partial product can be referred to by its significance. The number ofbits that a copy of the multiplicand value would be required to beshifted to generate a partial product for a one bit value in amultiplier value designates the significance of the partial product.Hence, a partial product that may potentially include a copy of themultiplicand value without requiring any shifting would havesignificance zero. Likewise, a partial product that may potentiallyinclude a copy of the multiplicand value shifted toward the mostsignificant bit by 8 bits would have significance eight. Therefore, whenthere are several partial products in a set, the partial product thathas the least significance is called the least significant partialproduct and the partial product that has the most significance is calledthe most significant partial product. If there are partial products withsignificance 0 to 15, the most significant partial product is thepartial product with significance 15 and the least significant partialproducts is the partial product with significance 0.

In an embodiment, Booth recoding (e.g., one-bit Booth, two-bit Booth orbit-pair recoding, etc) can be used to reduce the number of partialproducts that are required to sum two n-bit binary numbers. Unlike thepartial products of the long hand technique, which may contain either azero value or a copy of the multiplicand value, a two-bit Booth recodedpartial product may contain a value of zero or 1×M, 2×M, −1×M, and −2×Mvalues (where M is the multiplicand value). Two-bit Booth recodingguarantees that every partial product with an odd numbered significancewill have the value zero. Thus, two-bit Booth recoding requires only(floor(n/2)+1) partial products to generate the product of both signedand unsigned n-bit binary numbers (where floor(x) equals the greatestinteger not exceeding x).

In an embodiment, to multiply two 32-bit single values, only seventeenBooth recoded partial products are needed. To multiply two 16-bit vectorvalues, only nine Booth recoded partial products are needed. Therefore,each adder array 402 and 404 is implemented to sum nine partial productsso that each adder array can produce a product of two 16-bit vectorvalues. When both adder arrays 402 and 404 are used jointly, they sum upto eighteen partial products. Since only 17 Booth recoded partialproducts should be summed when multiplying two 32-bit single values, oneof the eighteen partial products that are input to the two adder arrays402 and 404 is assigned the value of zero.

In generating partial products for each adder array 402 and 404, Boothrecoder 500 treats one of the operands 110 and 112 as the multipliervalue and the other as the multiplicand value. When operands 110 and 112represent vectors, Booth recoder 500 and partial product selector 502create nine Booth recoded partial products for the product of the rightvector values and assigns these partial products to adder array 402. Inaddition, Booth recoder 500 and partial product selector 502 create anadditional nine Booth recoded partial products for the product of theleft vector values and assigns them to the adder array 404.

When operands 110 and 112 each contain single values, Booth recoder 500and partial product selector 502 create seventeen Booth recoded partialproducts for the single values and assigns the eight lowest significantBooth recoded partial products to adder array 402 and the nine highestsignificant Booth recoded partial products to adder array 404. Inaddition, the partial product selector 502 provides a partial productwith a value of zero for a ninth partial product for adder array 402.The seventeen Booth recoded partial products may be divided among thetwo adder arrays 402 and 404 in different ways.

In an embodiment, adder arrays 402 and 404 are configured to includeinputs that expect partial products with specific significance. Since apartial product with significance s contains only zero bit valuesbetween bit position s and the least significant bit, an adder array canbe implemented to sum its inputs more efficiently by requiring eachpartial product input to be of a specific significance. By requiringeach partial product input to be of a specific significance, the adderarray avoids unnecessarily addition of portions of the partial productsthat are known to contain only zero bit values. Therefore, the adderarray 402 is configured to accept partial products with significance 0,2, 4, 6, 8, 10, 12, 14, and 16, and adder array 404 is configured toaccept partial products with significance 16, 18, 20, 22, 24, 26, 28,30, and 32. Partial product with significance 32 is only required tosupport unsigned values. With this configuration, the significance ofthe most significant partial product 536 for adder array 402 is equal tothe significance of the least significant partial product 538 for adderarray 404.

When operands 110 and 112 each contain single values, the significanceof the seventeen Booth recoded partial products of the single values are0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, and 32, andmap to the inputs of adder arrays 402 and 404. So that the partialproduct with significance 16 is not added twice, the partial productselector 502 assigns a zero value to the most significant partialproduct 536 for adder array 402. Alternatively, partial product selector502 may assign a zero value to the least significant partial product 538for adder array 404.

When operands 110 and 112 contain vector values, the significance of thenine Booth recoded partial products are 0, 2, 4, 6, 8, 10, 12, 14, and16 for both the products of left and right vector values. For the rightvector values, the nine Booth recoded partial products map to the inputsof adder array 402. For the left vector values, the nine Booth recodedpartial products are shifted 16 bits toward the most significant bit tomap to the inputs of adder array 404. After adder array 404 adds thenine Booth recoded partial products for the left vector values, theresult may be shifted 16 bits toward the least significant bit to removethe effect of the initial 16 bit shift toward the most significant bit.

In an embodiment, adder array 402 is implemented as an array of rows ofcarry-save adders 504, 508, 506, 508, 510, 512, 514, and 516. Adderarray 404 is implemented as an of an array of rows of carry-save adders520, 522, 524, 526, 528, 530, and 532. Carry-save adders take threeinputs and produces two outputs referred to as the carry and the save.Adder array 402 takes as input nine partial products and outputs a finalcarry value 542 and a final save value 540. Adder array 404 takes asinput nine partial products and outputs a final carry value 546 and afinal save value 544.

Referring to FIG. 5B, in an embodiment, combiner 406 includesshift-saturate units 570 and 572, adder array 586, 16-bit adders 582 and584, and saturation unit 590. Combiner 406 takes as its input carryvalues 542 and 546, save values 540 and 544, and the value representedby operand 114 to combine them in different ways to support variousoperations.

Shift-saturate units 570 and 572 shift and/or saturate inputs from adderarrays 402 and 404 respectively. The carry value 542 and save value 540are shifted and/or saturated by shift-saturate unit 570, for example, ifthey represent fractional values. Shift-saturate unit 570 outputs carryvalue 576 and save value 574 Similarly, carry value 546 and save value544 are shifted and/or saturated by shift-saturate unit 572, forexample, if they represent fractional values. Furthermore, when operands110 and 112 represent vectors, carry value 546 and save value 544 may beshifted toward the least significant bit to match the bit significanceof carry value 576 and save value 574. This is done so that the decimalpoints of the carry values 546 and 542 and save values 544 and 540 areproperly aligned and can be added to generate the dot product.Shift-saturate unit 572 outputs carry value 580 and save value 578.

When operands 110 and 112 each represent single values, carry values 580and 576 and save values 578 and 574 are added by adder array 586 tosupport MULT type operations. Furthermore, carry values 580 and 576 andsave values 578 and 574 are added with the value represented by operand114 by adder array 586 to support MAQ type operations. Result 588 ofadder array 586 may be saturated by saturation unit 590 if theaccumulated value overflows or underflows. After result 588 is processedby saturation unit 590, final result 116 is provided by combiner 406 andis stored in one of accumulation registers 108.

Table 1, shown below, provides exemplary pseudo code for a MULT typeoperation that can be implemented, for example, using processor core100. In the pseudo code, an accumulation register is shown as a HI andLO portion. In an embodiment, this pseudo code is implemented by aninstruction having a format as illustrated in FIG. 8A.

TABLE 1 Pseudo code for an exemplary MULT type operation. Format: MULTrs, rt Purpose: To multiply registers rs and rt and store the result inthe accumulation register. Description: ac ← (rs_(31..0) * rt_(31..0))Operation: MULT   HI[ac]||LO[ac] ← (GPR[rs]_(31..0) * GPR[rt]_(31..0))

Table 2, shown below, provides exemplary pseudo code for a MAQ typeoperation that can be implemented, for example, using processor core100. In an embodiment, this pseudo code is implemented by an instructionhaving a format as illustrated in FIG. 8B.

TABLE 2 Pseudo code for an exemplary MAQ type operation. Format:MAQ_S.W.PHR ac, rs, rt Purpose: To multiply one set of fractional vectorelement using full-size intermediate products and then accumulate intothe specified accumulator register. Description: ac ← sat32(ac +sat32(rs_(15..0) * rt_(15..0))) Operation: MAQ_S.W.PHR  Setouflag(GPR[rs], GPR[rt], satcond)   if satcond then     temp ←0x7FFFFFFF   else     temp ← (GPR[rs]_(15..0) * GPR[rt]_(15..0)) << 1  endif   temp2 ← (HI[ac]||LO[ac]) + temp   HI[ac]||LO[ac] ← temp2function Setouflag(s, t, satcond)   satcond ← (s_(15..0) = 0x8000) and(t_(15..0) = 0x8000) endfunction Setouflag

To support MULQ type operations, when operands 110 and 112 representvectors, carry value 580 and save value 578 are summed by 16-bit adder584. Carry value 576 and save value 574 are summed by 16-bit adder 582.The outputs of 16-bit adders 584 and 582 are combined to generate finalresult 118, which is ultimately stored in a register of GPRs 102.

Table 3, shown below, provides exemplary pseudo code for a MULQ typeoperation that can be implemented, for example, using processor core100. In an embodiment, this pseudo code is implemented by an instructionhaving a format as illustrated in FIG. 8C.

TABLE 3 Pseudo code for an exemplary MULQ type operation. Format:MULQ_RS.PH rd, rs, rt Purpose: Multiply two vector fractional Q15 valueswith optional saturation. Description: rd ← sat16(rs_(31:16) *rt_(31:16)) || sat16(rs_(15:0) * rt_(15:0)) Operation: MULQ_RS.PH  Setouflag(GPR[rs], GPR[rt], satcond1, satcond2)   if satcond1 then    temp1 ← 0x7FFFFFFF   else     temp1 ← ((GPR[rs]_(31..16) *GPR[rt]_(31..16)) << 1) +     0x8000   endif   if satcond2 then    temp2 ← 0x7FFFFFFF   else     temp2 ← ((GPR[rs]_(15..0) *GPR[rt]_(15..0)) << 1) + 0x8000   endif   GPR[rd] ← temp1_(31..16) ||temp2_(31..16) function Setouflag(s, t, satcond1, satcond2)   satcond1 ←(s_(31..16) = 0x8000) and (t_(31..16) = 0x8000)   satcond2 ← (s_(15..0)= 0x8000) and (t_(15..0) = 0x8000) endfunction Setouflag

When operands 110 and 112 are vectors, a dot-product accumulate (DPA)operation ( may be supported by having shift-saturate unit 572 shiftcarry value 546 and save value 544 to produce carry value 580 and savevalue 578, which match the bit significance of carry value 576 and savevalue 574. Once carry values 580 and 576 and save values 578 and 574match in significance, so that their decimal points are aligned, theyare added by adder array 586 with the value represented by operand 114to provide DPA type operations.

Table 4, shown below, provides exemplary pseudo code for a DPA typeoperation that can be implemented, for example, using processor core100. In an embodiment, this pseudo code is implemented by an instructionhaving a format as illustrated in FIG. 8D.

TABLE 4 Pseudo code for an exemplary DPA type operation. Format:DPAU.H.QBL ac, rs, rt Purpose: To generate the dot-product of two bytesfrom the left-aligned vector positions using full-size intermediateproducts, followed by a further addition of the resulting dot-product tothe specified accumulator register. Description: ac ← ac +dot-product(rs[i],rt[i]) Operation:   temp1 ← (GPR[rs]_(31..24) *GPR[rt]_(31..24))   temp2 ← (GPR[rs]_(23..16) * GPR[rt]_(23..16))  HI[ac]||LO[ac] ← HI[ac]||LO[ac] + temp1_(15..0) + temp2_(15..0)

To support multiply-difference accumulate (MULSAQ) type operations, thepresent invention inverts the sign bits when Booth recoding the productof one of the vector values. Inverting the sign bits during Boothrecoding is referred to herein as negated Booth recoding. To performnegated Booth recoding, both the −2×M and 2×M values and the −1×M and1×M values are swapped in generating the Booth recoded partial products.The sum of the negated Booth recoded partial products produces thenegative value of the product of the multiplier value and themultiplicand value.

In supporting a MULSAQ type operation, Booth recoder 500 and partialproduct selector 502 generate negated Booth recoded partial products forthe right vector values. For the left vector values, Booth recoder 500and partial product selector 502 generate normal Booth recoded partialproducts. Thereafter, the generated partial products are operated on bymultiplier 106 as though it were performing a DPA operation. Since theright vector values are recoded using negated Booth recoding, thenegative value of the product of the right vector values will be addedto the product of the left vector values, thereby producing amultiply-difference result. The multiply-difference result can be addedwith the value represented by operand 114 to produce a result 116, whichis stored in one of accumulation registers 108.

Table 5, shown below, provides exemplary pseudo code for a MULSAQ typeoperation that can be implemented, for example, using processor core100. In an embodiment, this pseudo code is implemented by an instructionhaving a format as illustrated in FIG. 8E.

TABLE 5 Pseudo code for an exemplary MULSAQ type operation. Format:MULSAQ_S.W.PH ac, rs, rt Purpose: To multiply and subtract twofractional vector elements using full-size intermediate products andthen accumulate into the specified accumulator register. Description: ac← ac + (sat32(rs_(31..16) * rt_(31..16)) − sat32(rs_(15..0) *rt_(15..0))) Operation: MULSAQ_S.W.PH   Setouflag(GPR[rs], GPR[rt],satcond1, satcond2)   if satcond1 then     temp1 ← 0x7FFFFFFF   else    temp1 ← (GPR[rs]_(31..16) * GPR[rt]_(31..16)) << 1   endif   ifsatcond2 then     temp2 ← 0x7FFFFFFF   else     temp2 ←(GPR[rs]_(15..0) * GPR[rt]_(15..0)) << 1   endif   HI[ac]||LO[ac]←(HI[ac]||LO[ac]) + (temp1 − temp2) function Setouflag(s, t, satcond1,satcond2)   satcond1 ← (s_(31..16) = 0x8000) and (t_(31..16) = 0x8000)  satcond2 ← (s_(15..0) = 0x8000) and (t_(15..0) = 0x8000) endfunctionSetouflag

To handle dot-product subtract accumulate (DPS) type operations, Boothrecoder 500 and partial product selector 502 generate negated Boothrecoded partial products for both left and right vector values.Thereafter, the generated partial products are operated on by multiplier106 as though it were performing a DPA operation. Since vector valuesare recoded using negated Booth recoding, the negative value of theproduct of the right vector values and the negative value of the productof the left vector values will be generated. These negative values areadded by combiner 406 with the value represented by operand 114 toproduce a result 116, which is stored in one of accumulation registers108.

Table 6, shown below, provides exemplary pseudo code for a DPS typeoperation that can be implemented, for example, using processor core100. In an embodiment, this pseudo code is implemented by an instructionhaving a format as illustrated in FIG. 8F.

TABLE 6 Pseudo code for an exemplary DPS type operation. Format:DPSU.W.QBL ac, rs, rt Purpose: To generate the dot-product of two bytesfrom left-aligned vector positions using full-size intermediateproducts, followed by subtraction into the specified accumulatorregister. Description: ac ← ac − dot-product(rs[i],rt[i]) Operation:  temp1 ← (GPR[rs]_(31..24) * GPR[rt]_(31..24))   temp2 ←(GPR[rs]_(23..16) * GPR[rt]_(23..16))   HI[ac]||LO[ac] ← HI[ac]||LO[ac]− (temp1_(15..0) + temp2_(15..0))

In an embodiment where multiplier 106 is not required to operate onvectors containing two 16-bit unsigned values, multiplier 106 supportsmultiplication of single values and other vector formats (e.g., vectorscontaining two 16-bit signed values, vectors containing one 8-bitunsigned value and one 16-bit unsigned value, etc) utilizing only 17partial products. In such an embodiment, adder array 402 is configuredto accept eight partial products with significance 0, 2, 4, 6, 8, 10,12, and 14. Adder array 404 is configured to accept nine partialproducts with significance 16, 18, 20, 22, 24, 26, 28, 30 and 32. Sincethe two adder arrays 402 and 404 support up to 17 partial products, thetwo adder arrays are used jointly to compute the product of signed orunsigned 32-bit single values. But, since adder array 402 is configuredto receive only 8 partial products, it is unable to generate the productof two 16-bit unsigned vector values.

In an embodiment where multiplier 106 does not handle vectors containingtwo 16-bit unsigned vector values, multiplier 106 generates the productof an unsigned 16-bit vector value and an unsigned 8-bit vector value byselecting the 16-bit vector value as the multiplicand value. Forexample, when one of the operands 110 and 112 represent a vector withtwo 16-bit vector values and the other operand represents a vector withtwo 8-bit vector values, partial product generator 400 selects the16-bit vector values as the multiplicand value and the 8-bit vectorvalues as the multiplier value. Since only five partial products arerequired to produce a product when the multiplier value is an 8-bitunsigned value, each adder array unit 402 and 404 is able to generatethe product of one unsigned 16-bit vector value and one unsigned 8-bitvector value. In supporting the multiplication of one unsigned 16-bitand one unsigned 8-bit value, the partial product generator 400 may needto swap operands 110 and 112. Furthermore, the partial product generator400 may need to zero extend the partial products it generates.

Hence, in an embodiment where multiplier 106 does not handle vectorscontaining two 16-bit unsigned vector values, the multiplier 106utilizes only adder array 404 to generate the product of two 16-bitunsigned vector values. For example, when operands 110 and 112 representvectors each containing one 8-bit unsigned value and one 16-bit unsignedvalue, partial product generator 400 generates partial products for the16-bit unsigned values for adder array 404 and generates partialproducts for the 8-bit unsigned values for adder array 402. Combiner 406combines the results generated by adder arrays 404 and 402 in differentways to produce a final result 116 or 118 for various types ofoperations. To ensure that 16-bit unsigned vector values are operatedonly by adder array 404, the vector values may need to be swapped inpartial product generator 400 and the results of adder arrays 402 and404 may need to be swapped in combiner 406.

Table 7, shown below, provides exemplary pseudo code for a MULEU typeoperation that can be implemented, for example, using processor core100. In an embodiment, this pseudo code is implemented by an instructionhaving a format as illustrated in FIG. 8G.

TABLE 7 Pseudo code for an exemplary MULEU type operation. Format:MULEU_S.PH.QBL rd, rs, rt Purpose: To multiply a pair of 8-bit vectorvalues to a pair of 16-bit vector values with optional saturation.Description: rd ← sat16(rs_(31:24) * rt_(31:16)) || sat16(rs_(23:16) *rt_(15:0)) Operation: MULEU_S.PH.QBL   Setouflag(GPR[rs], GPR[rt],tempu, tempv, satcondu, satcondv)   if satcondu then     tempu ← 0xFFFF  endif   if satcondv then     tempv ← 0xFFFF   endif   GPR[rd]←tempv_(15..0) || tempu_(15..0) function Setouflag(s, t, tempu, tempv,satcondu, satcondv)   tempu ← (s_(23..16) * t_(15..0))   tempv ←(s_(31..24) * t_(31..16))   satcondu ← tempu > 0XFFFF   satcondv ←tempv > 0xFFFF endfunction Setouflag

The principles outlined in the embodiments of the present inventiondescribed herein may be applied to support vectors having more than twovalues. In such embodiments, a separate adder array unit is used togenerate products for values of vectors and adder array units are usedjointly to generate products for larger data types. In an embodiment, a64-bit processor may support 64-bit single values and vectors containingtwo 32-bit values or four values that are 16-bit or lower. In such anembodiment, four separate adder array units may be utilized individuallyto generate up to four products of 16-bit or lower vector values.Furthermore, two of the adder array units may be used jointly togenerate up to two products of 32-bit vector values. Finally, all fouradder array units may be used jointly to generate the product of two64-bit single values. Applying the technique of the present invention, avariety of GPP and DSP data formats, operand sizes and operations can besupported.

In an embodiment, multiplier 106 may be pipelined. Pipelining mayproduce data hazards in the pipeline as multiple operations areperformed back to back. Such data hazards may be handled by forwardingintermediate and final results from one stage of the pipeline toanother. Other techniques such as inserting stalls or bubbles into thepipeline may be utilized to overcome data hazards in a pipelinedmultiplier 106.

FIG. 6 is a flow chart illustrating the steps of a method 600 formultiplying vectors and/or single values. Method 600 includes sevensteps. Method 600 begins with step 602.

In step 602, a first input and a second input are received. The firstinput and the second input each represent either a single value or avector having a first value and a second value. In an embodiment, thefirst input and second input may contain either fractional or integervalues.

In step 604, a plurality of first partial products and a plurality ofsecond partial products are produced. The first partial products and thesecond partial products may each include the partial products for aproduct of vector values or the partial products of the single values.The first partial products include a most significant partial productand the second partial products include a least significant partialproduct. In an embodiment, the significance of second partial productsare greater or equal to the significance of first partial product.

In step 606, if the first input and the second input represent vectors,the most significant partial product of the first partial products isgenerated. This is based on the first vector value of the first inputand the first vector value of the second input.

In step 608, if the first input and the second input represent singlevalues, either the most significant partial product of the first partialproducts or the least significant partial product of the second partialproducts is assigned the value of zero. In one embodiment, one of theleast significant partial products and most significant partial productsof the first partial products and the second partial products isassigned the value of zero. In another embodiment, any one of the firstpartial products or the second partial products is assigned the value ofzero.

In step 610, the first partial products are added to generate a firstresult.

In step 612, the second partial products are added to generate a secondresult.

In step 614, the first result and the second result are combined togenerate a final result.

FIG. 7 is a flow chart illustrating the steps of a method 700 forperforming a multiply and subtract operation. Method 700 includes sixsteps. Method 700 begins with step 702.

In step 702, a first input and a second input representing vectorshaving a first value and a second value are received. In an embodiment,the first input and second input may contain either fractional orinteger values

In step 704, a plurality of first partial products are produced based onthe first vector value of the first input and the first vector value ofthe second input. Each first partial product is a negated Booth recodedpartial product. When the first partial products are summed, the resultis the negative product of the first vector value of the first input andthe first vector value of the second input.

In step 706, a plurality of second partial products are produced basedon the second value of the first input and the second value of thesecond input. Each second partial product is a normal Booth recodedpartial product. When the second partial products are summed, the resultis the positive product of the second vector value of the first inputand the second vector value of the second input.

In step 708, the first partial products are added to generate a firstresult.

In step 710, the second partial products are added to generate a secondresult.

In step 712, the first result and the second result are combined togenerate a final result.

While various embodiments of the present invention have been describedabove, it should be understood that they have been presented by way ofexample, and not limitation. It will be apparent to persons skilled inthe relevant computer arts that various changes in form and detail canbe made therein without departing from the spirit and scope of theinvention.

For example, in addition to multiplier implementations using hardware(e.g., within or coupled to a Central Processing Unit (“CPU”),microprocessor, microcontroller, digital signal processor, processorcore, System on Chip (“SOC”), or any other programmable or electronicdevice), implementations may also be embodied in software (e.g.,computer readable code, program code, instructions and/or data disposedin any form, such as source, object or machine language) disposed, forexample, in a computer usable (e.g., readable) medium configured tostore the software. Such software can enable, for example, the function,fabrication, modeling, simulation, description, and/or testing of theapparatus and methods described herein. For example, this can beaccomplished through the use of general programming languages (e.g., C,C++), GDSII databases, hardware description languages (HDL) includingVerilog HDL, VHDL, and so on, or other available programs, databases,and/or circuit (i.e., schematic) capture tools. Such software can bedisposed in any known computer usable medium including semiconductor,magnetic disk, optical disk (e.g., CD-ROM, DVD-ROM, etc.) and as acomputer data signal embodied in a computer usable (e.g., readable)transmission medium (e.g., carrier wave or any other medium includingdigital, optical, or analog-based medium). As such, the software can betransmitted over communication networks including the Internet andintranets.

It is understood that the apparatus and method embodiments describedherein may be included in a semiconductor intellectual property core,such as a microprocessor core (e.g., embodied in HDL) and transformed tohardware in the production of integrated circuits. Additionally, theapparatus and methods described herein may be embodied as a combinationof hardware and software. Thus, the present invention should not belimited by any of the above-described exemplary embodiments, but shouldbe defined only in accordance with the following claims and theirequivalence.

1. A processor core to execute an instruction to perform a multiply andsubtract operation, comprising: a decoder to decode the instruction anddetect an operation code, a first operand, and a second operand, thefirst and second operands each having a first value and a second value;a plurality of general purpose registers (GPRs) including a first GPR tostore the first operand and a second GPR to store the second operand;and an execution unit, coupled to the general purpose registers and anaccumulation register, that includes: a partial product generator thatgenerates a plurality of first partial products and a plurality ofsecond partial products using the first and second operands, whereineach first partial product is a negated Booth recoded partial productbased on the first value of the first operand and the first value of thesecond operand, and wherein each second partial product is a secondBooth recoded partial product based on the second value of the firstoperand and the second value of the second operand, wherein theplurality of first partial products has higher bit significance than theplurality of second partial products; a plurality of first adders,coupled to the partial product generator, that generates a first resultfor the plurality of first partial products; a plurality of secondadders, coupled to the partial product generator, that generates asecond result for the plurality of second partial products; and acombiner, coupled to the first adders and the second adders, thatgenerates a final result based on the first result, and the secondresult if the first operand and the second operand represent singlevalues, the partial product generator assigns a value of zero to eithera most significant partial product of the plurality of second partialproducts or to a least significant partial product of the plurality offirst partial products, wherein the combiner further comprises: asaturation unit, coupled to a shift unit, wherein if the first value ofthe first operand and the first value of the second operand each equalnegative one, the saturation unit replaces the first result with asaturation result; and if the second value of the first operand and thesecond value of the second operand each equal negative one, thesaturation unit replaces the second result with the saturation result.2. The processor core of claim 1, wherein the combiner furthercomprises: a third plurality of adders, coupled to the saturation unit,that generates the final result based on the first result, the secondresult, the operation code, and an accumulation value.
 3. A multiplierthat implements a multiply and subtract operation in response to aninstruction having a first operand and a second operand, each of thefirst and second operands having a first value and a second value,comprising: a partial product generator circuit that generates aplurality of first partial products and a plurality of second partialproducts using the first and second operands wherein each first partialproduct is a negated Booth recoded partial product based on the firstvalue of the first operand and the first value of the second operand,and wherein each second partial product is a second Booth recodedpartial product based on the second value of the first operand and thesecond value of the second operand, wherein the plurality of firstpartial products has higher bit significance than the plurality ofsecond partial products; a plurality of first adders, coupled to thepartial product generator, that generates a first result for theplurality of first partial products; a plurality of second adders,coupled to the partial product generator, that generates a second resultfor the plurality of second partial products; and a combiner, coupled tothe first adders and the second adders, that generates a final resultbased on the first result, and the second result wherein if the firstoperand and the second operand represent single values, the partialproduct generator assigns a value of zero to either a most significantpartial product of the plurality of second partial products or to aleast significant partial product of the plurality of first partialproducts, wherein the combiner further comprises: a saturation unit,coupled to a shift unit, wherein if the first value of the first operandand the first value of the second operand each equal negative one, thesaturation unit replaces the first result with a saturation result; andif the second value of the first operand and the second value of thesecond operand each equal negative one, the saturation unit replaces thesecond result with the saturation result.
 4. The multiplier of claim 3,wherein the combiner further comprises: a third plurality of adders,coupled to the saturation unit, that generates the final result based onthe first result, the second result, the instruction, and anaccumulation value.
 5. A computer readable storage medium having storedthereon computer readable program code describing a multiplier to causea processor to perform a multiplication, the computer readable programcode comprising: first computer readable program code to describe apartial product generator that generates a plurality of first partialproducts and a plurality of second partial products given a firstoperand and a second operand, each of the first and second operandshaving a first value and a second value, wherein each first partialproduct is a negated Booth recoded partial product based on the firstvalue of the first operand and the first value of the second operand,and wherein each second partial product is a second Booth recodedpartial product based on the second value of the first operand and thesecond value of the second operand, the plurality of first partialproducts has higher bit significance than the plurality of secondpartial products; second computer readable program code to describe aplurality of first adders, coupled to the partial product generator,that generate a first result for the plurality of first partialproducts; third computer readable program code to describe a pluralityof second adders, coupled to the partial product generator, thatgenerate a second result for the plurality of second partial products;fourth computer readable program code to describe a combiner, coupled tothe first adders and the second adders, that generates a final resultbased on the first result and the second result, wherein if the firstoperand and the second operand represent single values, the partialproduct generator assigns a value of zero to either a most significantpartial product of the plurality of second partial products or to aleast significant partial product of the plurality of first partialproducts; and fifth computer readable program code to describe asaturation unit coupled to a shift unit, wherein if the first value ofthe first operand and the first value of the second operand each equalnegative one, the saturation unit replaces the first result with asaturation result and if the second value of the first operand and thesecond value of the second operand each equal negative one, thesaturation unit replaces the second result with the saturation result.6. The computer readable storage medium of claim 5, wherein the codedescribing the combiner includes: sixth computer readable program codeto describe a third plurality of adders, coupled to the saturation unit,that generate the final result based on the first result, the secondresult, the instruction, and an accumulation value.
 7. A method ofexecuting an instruction to perform a multiply and subtract operation,comprising: decoding, using an electronic decoder, the instruction todetect an operation code, a first operand and a second operand, thefirst and second operands each having a first value and a second value;receiving the first operand and the second operand; producing aplurality of first partial products, using a Booth recoder, each firstpartial product being a negated Booth recoded partial product based onthe first value of the first operand and the first value of the secondoperand; producing a plurality of second partial products, using theBooth recoder each second partial product being a second Booth recodedpartial product based on the second value of the first operand and thesecond value of the second operand, wherein the plurality of firstpartial products has higher bit significance than the plurality ofsecond partial products; adding the plurality of first partial productsto generate a first result; adding the plurality of second partialproducts to generate a second result; and combining, using an electroniccombiner, the first result and the second result to generate a finalresult, wherein if the first operand and the second operand representsingle values, the partial product generator assigns a value of zero toeither a most significant partial product of the plurality of secondpartial products or to a least significant partial product of theplurality of first partial products, wherein if the first value of thefirst operand and the first value of the second operand each equalnegative one, the saturation unit replaces the first result with asaturation result, and wherein if the second value of the first operandand the second value of the second operand each equal negative one, thesaturation unit replaces the second result with the saturation result.8. The method of claim 7, further comprising: generating the finalresult based on the first result, the second result, the operation code,and an accumulation value.